/**
 * Licensed under the Apache License Version 2.0.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package net.interknit.knitter.client;

/**
 *
 */
public class CGMain
{
	public static void main(String[] args)
	{
		CodeGenTask task = new CodeGenTask();

		String u = "", d = "", p = "", adp = "", swf = "";

		for(int i = 0; args != null && i < args.length - 1; i++)
		{
			if("-u".equals(args[i])) u = args[i + 1];
			else if("-d".equals(args[i])) d = args[i + 1];
			else if("-p".equals(args[i])) p = args[i + 1];
			else if("-useDerivedPackageName".equals(args[i])) adp = args[i + 1];
			else if("-sourceWriterFactory".equals(args[i])) swf = args[i + 1];
		}

		if(u == null || u.isEmpty())
		{
			System.out.println("Usage: java " + CodeGenTask.class.getName() + " " +
					"-u <url or path of the endpoint.xml of the target service> " +
					"[-d <output source dir for generated code>] " +
					"[-p <root package name for generated code>] " +
					"[-appendDerivedPackageName <append derived package name to root package name>] " +
					"[-sourceWriterFactory <source writer factory classname>]"
					);
		}
		else
		{
			task.setUrl(u);
			task.setSrcdir(d);
			task.setPackagename(p);
			task.setAppendDerivedPackageName(adp);
			task.setSourceWriterFactory(swf);

			task.execute();
		}
	}
}
